<?php
require('conn.php');
require('session.php');
require('functions.php');
$type_arr=explode(',',$config['UserAddArticleType']);
//开启前台发布
if($config['UserAddArticle']==0){
		echo "<script>alert('前台会员不支持发布文章');location.href='ucenter.php'</script>";
		exit;	
}
//微信文章导入
if($_POST){
	require('QueryList.class.php');
	$long=guolv(trim($_POST['long']));
	$title=guolv(trim($_POST['title']));
	$type_id=guolv(trim($_POST['type_id']));
	$html=get_contents($long);
	$money=$type_arr[2];
	$html=str_replace('data-src','src',$html);
	$caiji = array(
		"title"=>array(".rich_media_title:first","text"),
		"content"=>array("#js_content","html"),
		
		);
	$quyu='';
	$hj = QueryList::Query($html,$caiji,$quyu);
	$arr = $hj->jsonArr;
	if($title==''){
		$title=$arr[0]['title'];
	}
	$content=$arr[0]['content'];
	$pic=cut($html,'var msg_cdn_url = "','"');
	if(url_exists($long)==1){
		echo "<script>alert('网址不存在');location.href='weixin.php'</script>";
		exit;		
	}
	if(is_numeric($type_id)==false){
		echo "<script>alert('分类不存在');location.href='weixin.php'</script>";
		exit;		
	}	
	$row=$mysql->query("select * from `article` where `title`='{$title}' limit 1");
	if(!$row){
		$arr=array(
			'top'=>0,
			'title'=>$title,
			'content'=>$content,
			'pic'=>$pic,
			'type'=>$type_id,
			'pv'=>0,
			'sh'=>0,
			'pv_max'=>'',
			'userid'=>$userdata['id'],
			'money'=>$money,
			'day'=>date("Y-m-d",time()),
		);
		$value=arr2s($arr);
		$mysql->query("insert into `article` {$value}");
		$id=mysql_insert_id();
		if($id!==0){
			echo "<script>alert('发布成功');location.href='{$site}/detail.php?aid={$id}&uid={$session['id']}'</script>";
			exit;
		}else{
			echo "<script>alert('发布错误');location.href='weixin.php'</script>";
			exit;			
		}
	}else{
		echo "<script>alert('文章已经存在');location.href='weixin.php'</script>";
		exit;		
	}
}
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0" />
<title>微信文章导入 - <?php echo $config['sitename']?></title>
<meta name="keywords" content="<?php echo $config['sitename']?>,微信文章导入" />
<meta name="description" content="<?php echo $config['sitename']?>微信文章导入">
 <link href="Css1/header.css" rel="stylesheet" type="text/css" />
<link href="Css1/home.css" rel="stylesheet" type="text/css" />
<script type=text/javascript > var app="/user" </script>
<script type="text/javascript" src="Scripts1/jquery.min.js"></script>
<script type=text/javascript src="Scripts1/jquery.common.js"></script>
 
</head>

<body class="mhome">

<?php include('header.php')?>
<form action="weixin.php" method="post">
<script>
	(function () {
		var menustate = document.getElementById('g-menustate');
		menustate.addEventListener("click", function (e) {
			if (menustate.checked) {
				$('#g-menustate').addClass('g-noscroll')
			}else {
				$('#g-menustate').removeClass('g-noscroll')
			}
		});
	})();
</script>    <style>
 .input-num {
  border: 0;
  font-size: 14px;
  height: 42px;
  line-height: 16px;
  margin-left: 25%;
  width: 75%;
}
.act-dialog h4 { text-align: center;}

.waves-input-wrapper .waves-button-input {
  left: 0;
  position: relative;
  top: 0;
  z-index: 1;
}
.waves-button, .waves-button:hover, .waves-button:visited, .waves-button-input {
  border: none;
  color: inherit;
  cursor: pointer;
  font-size: 1em;
  line-height: 1em;
  outline: 0;
  text-align: center;
  text-decoration: none;
  vertical-align: middle;
  white-space: nowrap;
  z-index: 1;
}
.big-btn input[type='button'] {
  width: 100%;
}
.input-box-item.right {
  width: 35%;
  margin-left: 20px;
  text-align: right;
}
.info{
            font-size: 14px;
            background: #fff;
            padding: 0px 12px;
            max-width: 616px;
            margin: 0 auto;
            line-height: 1.5em;
        }
        .block img{
            margin: 0 auto;
            max-width: 100%;
            display: block;
        }
        .input-box{
            padding: 16px 0;
            border: none;
            display: -webkit-box;
        }

       .input-num{
            margin-left: 0px;
            background: #f4f4f4;
            border-radius: 4px;
            width: 100%;
            padding-left:10px;
            box-shadow: 1px 1px 6px #ccc inset;
        }
        .input-box-item .input-box .bg-btn-red{
            margin:0;
        }
        .input-box-item.left{
            -webkit-box-flex:1;
        }
        .input-box-item.right{
            width: 35%;
            margin-left: 20px;
            text-align:right;
        }

        #mask{
            height: 100%;
            left: 0px;
            opacity: 0.9;
            position: fixed;
            top: 0px;
            width: 100%;
            z-index: 11;
            background: rgb(0, 0, 0);
            text-align:right;
            display:none;;
        }
        #mask img{
            height: 51px;
            /*margin:20px;*/
        }
        .share-txt{
            font-size:16px;
            color:#fff;
            padding:0 10px;
        }

        .adv {
            background: #fff;
            bottom: 0;
            color: #409bff;
            font-size: 20px;
            text-align: center;
            height: 48px;
            left: 0;
            line-height: 48px;
            position: fixed;
            width: 100%;
            z-index: 3;
            border-top: 1px solid #d1d1d1;
			margin-top: 15px;
        }

        .waves-button-input{
            padding: 1.1em 1.1em;
        }

        .intro{
            background: #fff;
            border-bottom: 1px solid #ddd;
        }
        .title{
            text-align: center;
        }
        .rule{
            background: #f6f6f6;
            padding: 15px 25px;
            line-height: 1.5em;
            border-bottom: 1px solid #ddd;
            border-top: 1px solid #ddd;
            color:#666;
        }
		.item{    margin-top:10px; margin-bottom:10px}
        .rule .title{
            padding: 5px;
        }
        .rule .text{
            font-size: 14px;
            padding: 5px 0;
        }.act-dialog_mask{position:absolute;top:0;right:0;bottom:0;left:0;z-index:96;width:100%;height:100%;background-color:rgba(0,0,0,.3)}.act-dialog_mod{position:fixed;top:0;right:0;bottom:0;left:0;z-index:100;width:100%;height:100%;display:-webkit-box;display:-ms-flexbox;-webkit-box-orient:vertical;-webkit-box-pack:center;-webkit-box-align:center;-ms-flex-direction:column;-ms-flex-pack:center;-ms-flex-align:center}.act-dialog{position:relative;z-index:99;width:280px;margin:8px 0;background-color:#fff;border-radius:5px}.act-dialog_bd{padding:10px}.act-dialog_ft{border-top:1px solid #d5d5d6;display:-webkit-box;display:-ms-flexbox;display:box}.act-dialog_btn__confirm,.act-dialog_btn__cancel{display:block;width:100%;height:50px;border:none;font-size:18px;text-align:center;-webkit-box-sizing:border-box;-ms-box-sizing:border-box;box-sizing:border-box;-webkit-box-flex:1;-ms-flex:1;box-flex:1}.act-dialog_btn__confirm{background:#fff;color:#02bb00}.act-dialog_btn__confirm:active{background:#f9f9f9}.act-dialog_btn__cancel{background:#fff;color:#353535}.act-dialog_btn__cancel:active{background:#f9f9f9}.act-dialog_ft button:first-child{border-right:1px solid #d5d5d6;border-radius:0 0 0 5px}.act-dialog_ft button:last-child{border-radius:0 0 5px}.act-dialog_ft button:only-child{border-radius:0 0 5px 5px;border-right:none}.act-dialog_fail{min-height:72px;text-align:center;display:-webkit-box;-webkit-box-orient:vertical;-webkit-box-pack:center;-webkit-box-align:center}.act-dialog_fail__t{color:#000;font-size:16px}.act-dialog_fail__d{padding-top:5px;color:#888;font-size:16px}.act-dialog_suc{padding:15px 5px 5px;overflow:hidden}.act-dialog_suc__view{float:left}.act-dialog_suc__img{display:block;width:75px;height:75px;-webkit-animation:tada 1s .2s ease 3 both}.act-dialog_suc__info{padding:0 0 0 10px;overflow:hidden}.act-dialog_suc__t{color:#000;font-size:18px}.act-dialog_suc__d{color:#353535;font-size:14px}.act-dialog_tips{clear:both;padding-top:15px;font-size:12px;text-align:center;color:#888}</style>
<div class="wrapper">
    <div class="block">
        <img src="Picture1/zhuanhuan.gif">
    </div>

    <div class="block info">
<div class="common-wrapper">
	<div style="padding:10px;text-align:center;margin:20px 20px 0;background:#fff;font-size:16px;border:1px dashed #f00;">复制微信公众号文章链接提交，自动转换分享链接</div>
	<div class="main">
		<form action="weixin.php" method="post">
			<div class="item">
				<input value="" class="input-num" name="title" value="" placeholder="自定义文章标题（可以留空）" type="text" />
			</div>			
			<div class="item">
				<input value=""  class="input-num"  name="long" value="" placeholder="请输入微信公众号文章网址" type="text" />
			</div>	
			<div class="item">
			<select name="type_id" class="input-num">	
			<option value="<?php echo $type_arr[0]?>"><?php echo $type_arr[1]?></option>
            </select>				
			</div>				
			<div class="item item-btns"> 
			<input type="submit" value="提交" class="waves-button-input" >
			</div>
		</form>
	</div>
</div>
    </div>
	<div class="act-dialog_mod" style="display:none;" id="masks">
        <div class="act-dialog" id="copyurl" style="display:none;">
            <div class="act-dialog_bd">
                <div class="act-dialog_suc">
                    <div class="act-dialog_suc__info">
                        <h4 class="act-dialog_suc__t" id="info">结果</h4>
                    </div>
                </div>
            </div>
            <div class="act-dialog_ft">
            <button class="btn-login" onClick="closemsg();">确定</button>
            </div>
        </div>
	</div>
    <div class="block fn-color-black rule">
	<p class="title">文章转换有什么作用：</p>
	<p class="text">
           如果您觉得在微信上看到哪篇文章好，想分享给朋友，但是直接分享是没有收益的，所以通过转换功能得到分享链接，分享获取到的链接就有收益了。

        </p>
        <p class="title">以下文章都是违规的：</p>
        <p class="text">
           1、文章标题和内容不能出现：转发、转疯了等文字,如："不转不是中国人"；"请好心人转发 一下"、"转发后一生平安"、"转疯了"、"必转"等；
        </p>
        <p class="text">
             2、什么是谣言？不知道，危言耸听的就不要传了，如自来水有毒、香蕉致癌等；
        </p>
        <p class="text">
            3、专心挣钱，莫谈国事！一经发现发布政治相关内容立刻封号；
        </p>
        <p class="text">
           4、在法律规定的范围内，分享赚 保留最终解释权.若发现用户恶意转换违规内容，将会对帐号进行封号处理，另外情节严重者将移交司法机关处理。
        </p>
		<p class="text"></p>
		<p class="text"></p>
		<p class="text"></p>
    </div> 
	<div class="adv" ><a class="fn-color-link" href="/ruhezhuanhuanwenzhang/">如何转换文章？</a></div>
	</div>
<div class="pop pop1" style="display: none;">
  <p class="error"><br />
  </p>
</div>
<script type="text/javascript">
	
	//提示窗口
	function errShow(content,time){
		$('.error').html(content);
		$('.pop1').show();
		setTimeout("errHide()",time);
	}
	
	//隐藏错误提示
	function errHide(){
		$('.pop1').hide();
		$('.error').text('');
		$("#error").html('');
		;
	}
	
	//登陆提示
	function loginShow(content){
		$('.error').html(content);
		$('.pop1').show();
	}
	
	//点击关闭错误提示
	$('.pop').live('click',function(){
		errHide();
	})
</script> 
<script type="text/javascript">
	$(function() {
		$("#wxurl").bind( "blur", function() {
			if ($("#wxurl").val() == '') {
				errShow("请输入微信文章链接！",3000);
			}
		});
	});
	function send(num){
	var wxurl=encodeURIComponent($("#wxurl").val()); 
	$("#masks").show();
	errShow("正在转换中请稍后，如果文章图片较多可能需要等待十多秒！",20000);
	$.ajax({ 
	 	  	type:'get',
	 	  	url:"http://m.bao-guang.com/api/weichat2content.html",
	 	  	data:{url:wxurl,signPackage:'e7b6oGMX1ywtSfEoMb8h/MUzJzgLWm41PCpD+u5YS+A6PkVqiVbjqeSq'},
	        dataType:"jsonp",
	        cache:false,
	        success:function(data){
				if(data.status==1){
				errShow(data.title+'转换成功',3000);
				$("#masks").show();
				$("#copyurl").show();
				$('#info').html("提交成功，在管理员审核通过后即可分享！"我的文章"中可以查看本次转换记录。");
				//$('#info').html("提交成功，在管理员审核通过后即可分享！长按复制分享链接，点击链接可进入文章页面<br/><p style='word-break: break-word; width:90%;margin:0 auto;-webkit-user-select: auto'><a href='"+data.url+"'> "+ data.url + "</a></p>");
				}else{
				errShow(data.message,3000);
				$("#masks").hide(); 
				$("#copyurl").hide();
				}
	        }
			});
	}
	function closemsg(){
				$("#masks").hide();
				$("#copyurl").hide();
	}
	</script>
<div style="display: none;">
</div>
</div>
</form>
</body>
</html>